import React, { Component } from 'react'

export default class componentName extends Component {
  state = {
    count: 8,
  }
  handleClick = () => {
    /* this.setState({ count: this.state.count + 1 })
    // 合成事件回调里面的表现也是异步的
    console.log(this.state.count) */
    this.setState({
      count: this.state.count + 1,
    })
    this.setState({
      count: this.state.count + 2,
    })
    this.setState({
      count: this.state.count + 3,
    })
    /* {
      count: this.state.count + 1,
      count: this.state.count + 2,
      count: this.state.count + 3,
    } */
    console.log(this.state.count)
  }
  render() {
    console.log('render')
    return (
      <div>
        <p>{this.state.count}</p>
        <button onClick={this.handleClick}>+1</button>
      </div>
    )
  }
  /* componentDidMount() {
    this.setState({ count: 9 })
    // 生命周期里面进行 setState 的操作是异步的表现
    console.log(this.state.count) // 8
  } */
}
